package sskj.regulatory.presentation.screen.forgetpas.forgetpasComplete

import android.content.Intent
import android.os.Bundle
import android.view.View
import com.qmuiteam.qmui.widget.dialog.QMUIDialog
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog
import kotlinx.android.synthetic.main.fragment_forgetpas_complete.*
import kotlinx.android.synthetic.main.fragment_forgetpas_complete.view.*
import kotlinx.android.synthetic.main.fragment_register_complete.view.*
import sskj.regulatory.R
import sskj.regulatory.domain.entity.user.UserEntity
import sskj.regulatory.presentation.base_mvp.base.BaseFragment
import sskj.regulatory.presentation.screen.forgetpas.forgetpasCaptcha.ForgetpasCompleteContract
import sskj.regulatory.presentation.screen.forgetpas.forgetpasCaptcha.ForgetpasCompletePresenter
import sskj.regulatory.presentation.screen.login.LoginFragment
import sskj.regulatory.presentation.screen.main.MainActivity
import sskj.regulatory.presentation.screen.register.RegisterCompleteContract
import sskj.regulatory.presentation.utils.delegates.bundle
import javax.inject.Inject

class ForgetpasCompleteFragment : BaseFragment<ForgetpasCompleteContract.View, ForgetpasCompleteContract.Presenter>(), ForgetpasCompleteContract.View {
    private val userEntity: UserEntity by bundle()

    @Inject
    lateinit var mPresenter: ForgetpasCompletePresenter

    override fun injectDependencies() = activityComponent.inject(this)

    override fun initPresenter() = mPresenter

    override val layoutResId: Int = R.layout.fragment_forgetpas_complete

    override fun onBackPressed(): Boolean {
        baseFragmentActivity.popBackStack(LoginFragment::class.java)
        return false
    }

    private fun initEvent() {
        mCacheView.forgetpas_complete_button.setOnClickListener {
            startFragment(LoginFragment())
        }
    }

    override fun showError(message: String?) {
        QMUIDialog.MessageDialogBuilder(getActivity())
                .setTitle("错误提示")
                .setMessage(message)
                .addAction("确定") { dialog, _ -> dialog.dismiss() }
                .create(R.style.QMUI_Dialog).show()
    }

    override fun initView() {
        initEvent()
    }
}